package com.dxtx.test.rotato;


import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import android.widget.Toast;

import com.dxtx.test.R;


public class RotatoAdapter extends BaseAdapter {
    private LayoutInflater inflater;
    int[] resIds = {R.mipmap.baby1, R.mipmap.jt, R.mipmap.liy, R.mipmap.lyf1,
            R.mipmap.mm1, R.mipmap.mm2, R.mipmap.ym, R.mipmap.jt, R.mipmap.liy, R.mipmap.lyf1};
    private Context context;
    private List<String> list;

    public RotatoAdapter(Context context, List<String> list) {
        this.context = context;
        this.list = list;
        inflater = LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public String getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {

        View view = inflater.inflate(R.layout.item_ring_menu, null);
        TextView textView1 = (TextView) view.findViewById(R.id.textView1);
        TextView textView2 = (TextView) view.findViewById(R.id.textView2);
        textView1.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                Toast.makeText(context, "点击了我,position=" + position, Toast.LENGTH_SHORT).show();
            }
        });
        textView1.setBackgroundResource(resIds[position]);
        textView2.setText(list.get(position));
        return view;
    }

}

